const coap  = require('coap')   
    , req   = coap.request('coap://localhost/shop') ;
var bl = require('bl'); 	
  
req.on('response', function(res) {  
  res.pipe(bl(function(err, data) {  
        var json = JSON.parse(data);  
        console.log(json);  
        process.exit(0);  
    }))  
})  
  
req.end()